<html>
<head><meta charset="utf-8"><title>custom order for BinaryHeap and BTree* · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/custom.20order.20for.20BinaryHeap.20and.20BTree*.html">custom order for BinaryHeap and BTree*</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="205732699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/custom%20order%20for%20BinaryHeap%20and%20BTree%2A/near/205732699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wim de With <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/custom.20order.20for.20BinaryHeap.20and.20BTree*.html#205732699">(Aug 02 2020 at 15:50)</a>:</h4>
<p>Why is there no option to specify a custom order for BinaryHeap and the BTree data structures? I know you can achieve it by implementing Ord on a wrapper type, or just use a crate, but I was wondering what the underlying reasons are that it isn't included in the stdlib.</p>



<a name="205732770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/custom%20order%20for%20BinaryHeap%20and%20BTree%2A/near/205732770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/custom.20order.20for.20BinaryHeap.20and.20BTree*.html#205732770">(Aug 02 2020 at 15:53)</a>:</h4>
<p>We'd need to add a defaulted type parameter to both, and because "ordering" is not the only thing you might want to specify (e.g., you might also want things like adjusting the "B" in B-trees) I believe we've been hesitant to do so so far.</p>



<a name="205732781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/custom%20order%20for%20BinaryHeap%20and%20BTree%2A/near/205732781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/custom.20order.20for.20BinaryHeap.20and.20BTree*.html#205732781">(Aug 02 2020 at 15:53)</a>:</h4>
<p>(Because <code>BTreeMap&lt;K, V, Ordering, B&gt;</code> is quite long, mostly, I think)</p>



<a name="205732841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/custom%20order%20for%20BinaryHeap%20and%20BTree%2A/near/205732841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/custom.20order.20for.20BinaryHeap.20and.20BTree*.html#205732841">(Aug 02 2020 at 15:55)</a>:</h4>
<p>A crate could provide a <code>CustomOrderBTree&lt;K, V, Order&gt;</code>, though, if someone wanted to write that up and I suspect that the API design learned from that would be helpful here.</p>



<a name="205732906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/custom%20order%20for%20BinaryHeap%20and%20BTree%2A/near/205732906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wim de With <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/custom.20order.20for.20BinaryHeap.20and.20BTree*.html#205732906">(Aug 02 2020 at 15:57)</a>:</h4>
<p>ah, so the reason is basically "we haven't seen a nice proposal yet"?</p>



<a name="205733078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/custom%20order%20for%20BinaryHeap%20and%20BTree%2A/near/205733078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/custom.20order.20for.20BinaryHeap.20and.20BTree*.html#205733078">(Aug 02 2020 at 16:01)</a>:</h4>
<p>to some extent, sure</p>



<a name="205733129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/custom%20order%20for%20BinaryHeap%20and%20BTree%2A/near/205733129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wim de With <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/custom.20order.20for.20BinaryHeap.20and.20BTree*.html#205733129">(Aug 02 2020 at 16:02)</a>:</h4>
<p>alright, thanks for the quick answer</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>